import Vue from 'vue'
import VueRouter from 'vue-router'
import main from '../views/Home/main'
// 把单独的页面的路由摘出来
import HomeRoute from '../views/Home/router'
import TypesRoute from '../views/types/router'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'main',
    // 默认渲染main
    component: main,
    redirect:'/index',
    children:[
      // ...扩展运算符把数组中的每一项陈列出来   
      // 把单独的Home页面的路由摘出来  为了不让页面太臃肿
        ...HomeRoute
    ]
  },
  {
    path: '/types',
    name: 'typesMain',
    redirect:'/types/index',
    component: () => import( '../views/types/main'),
    children:[
      ...TypesRoute
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
